package com.dailyblue.project.estate.house.controller;

import com.dailyblue.project.estate.commons.bean.House;
import com.dailyblue.project.estate.commons.util.JsonResult;
import com.dailyblue.project.estate.house.service.HouseService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/house")
public class LetterController {
    @Resource
    private HouseService houseService;
    @PostMapping
    public JsonResult save(House house) {
        return houseService.addHouse(house);
    }

    @GetMapping("/findOne/{id}")
    public JsonResult findOneHouse(@PathVariable("id") String houseId) {
        return houseService.findOneHouse(houseId);
    }

    @GetMapping
    public JsonResult findAllHouses() {
        return houseService.findAllHouses();
    }

    @DeleteMapping("/delete/{id}")
    public JsonResult deleteHouse(@PathVariable("id")String houseId) {
        return houseService.deleteHouse(houseId);
    }

    @PutMapping
    public JsonResult updateHouse(@RequestBody House house) {
        return houseService.updateHouse(house);
    }
}
